package com.wgj.android.ui.activity;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.jiaai.xui.XUI;
import com.jiaai.xui.utils.XAppUtils;
import com.jiaai.xui.utils.XPreferencesUtils;
import com.jiaai.xui.view.widget.XAlertMsgDialog;
import com.jiaai.xui.view.widget.XLoadingDialog;
import com.jiaai.xui.view.widget.XToast;
import com.jiaai.xui.view.widget.XTopbarView;
import com.wgj.android.R;
import com.wgj.android.WXFriendsAccessibilityService;
import com.wgj.android.utils.AccessibilityUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/11/1.
 */

public class FriendsCleanActivity extends AppCompatActivity {

    @BindView(R.id.topBar)
    XTopbarView topbarView;

    @BindView(R.id.msgEdit)
    EditText msgEdit;

    @BindView(R.id.msgContentView)
    View msgContentView;



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.friends_clean_activity);
        ButterKnife.bind(this);
        bindEvent();

    }

    private  void  bindEvent(){
         topbarView.setTopBarClickListener(new XTopbarView.OnTopBarClickListener() {
             @Override
             public void onBackClick() {
                 finish();
             }

             @Override
             public void onRightButClick() {
                 Intent intent=new Intent(getApplication(),FriendsCleanSettingActivity.class);
                 startActivity(intent);
             }
         });
    }

    @OnClick(R.id.startCleanBut)
    public void  sstartCleanButOnClick(View view){
        if(!AccessibilityUtil.checkWXFriendsAccessibilityServiceIsOpen(this)){
            new XAlertMsgDialog(this,"检测到旺旺通清粉功能未打开,是否前往打开?").setPositiveButton("开启").setListener(new XAlertMsgDialog.OnCloseListener() {
                @Override
                public void onClick(Dialog dialog, boolean b) {
                    if(b){
                        Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
                        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                        startActivity(intent);
                    }
                }
            }).show();
        }else {
             if(AccessibilityUtil.isOpenWeiXi()){
                 Intent intent=new Intent(getApplication(), WXFriendsAccessibilityService.class);
                 startService(intent);
                AccessibilityUtil.openWxiXi(getApplication());
            }
        }
    }
}
